﻿@model List<WebChatSites.Models.WeChat.CheapProductData>
@{
    ViewBag.Title = "降价商品";
    Layout = "~/Views/Shared/WeChatLayout.cshtml";
    DateTime dtBreaktime = DateTime.Parse("1990-01-01");
}
@*<meta http-equiv="refresh" content="20">*@
<style>

</style>
<script>
    bttime = '@Model.Last().UpdateTime.ToString("yyyy-MM-dd HH:mm:ss.fff")';
</script>
<div class="container" style="font-family: 微软雅黑; font-size: 14px;">
    <div style="text-align: center; font-size: 14px; height: 4em; line-height: 4em; font-weight: bold;">
        <div style="display: block; position: fixed; text-align: center; width: 100%; background: #f9f9f9; margin: 0 auto; left: 0; z-index: 999; box-shadow: 0 0 0.5em #ccc;">
            降价排行
        </div>

    </div>
    <div id="content">
        @for (int i = 0; i < @Model.Count; i++)
            {
                var m = Model[i];
                dtBreaktime = m.UpdateTime;
                var img = "/Content/Images/taobao.jpg";
                if (m.Shop == "淘宝")
                {
                    img = "/Content/Images/taobao.jpg";

                }
                if (m.Shop == "天猫")
                {
                    img = "/Content/Images/tmall.jpg";
                }
        <div class="row datarow" style="height: 5em; border-bottom: #ccc 1px solid; cursor: pointer;" data-id="@m.ProductId" data-shop="@m.Shop">
            <div class="col-xs-3">
                <img class="lazy img-list" data-original="@m.PicUrl" src="@img" style="width: 3em; margin: 1em auto; height: 3em;" />
            </div>
            <div class="col-xs-9" style="margin-top: 0.3em;">
                <div class="row" style="height: 3em;">
                    <div class="col-xs-7">
                        <div class="row" style="overflow: hidden; text-overflow: ellipsis; height: 3em;" title="@m.ProductName">@m.ProductName</div>
                        <div class="row" style="font-size: 10px;">
                            <div style="display:inline-block">@(m.Shop)</div>
                            <div style="display: inline-block; color: #b3acad; margin-left: 0.2em;">@m.UpdateTime.GetDateString()</div>
                        </div>
                    </div>
                    <div class="col-xs-5" style="text-align: right; text-align: right; line-height: 3em;">
                        <div class="row" style="height: 2em; line-height: 2em;">
                            <div class="col-xs-12">@(m.Price)元</div>
                        </div>
                        <div class="row" style="height: 2em; line-height: 2em;">
                            <div class="col-xs-12" style="font-size: 12px; color: #fa8072">@(m.Discount)折</div>
                        </div>
                    </div>
                </div>
                <div class="row" style="font-size: 10px;">


                </div>
            </div>

        </div>
        }
    </div>
    <div id="refresh" style="width: 3em;height:3em;position: fixed;display: block;bottom: 3em;right: 4em;">
        <img src="~/Content/images/refresh.png" style="width: 100%; height: 100%;" />
    </div>
</div>

@section scripts
{
    <script>

        $(function () {
            $(".datarow").unbind("click")
                .click(function () {
                    var shop = $(this).data("shop");
                    var id = $(this).data("id");
                    window.location.href = "/WeChat/ProductDetail?shop=" + shop + "&id=" + id;
                });
            $("img.lazy")
                .lazyload({
                    effect: "fadeIn"
                });
            $("#refresh").click(function () {
                window.location.href = window.location.href;
            });
            var loading = false;
            $(window).scroll(function () {
                if ((($(window).scrollTop() + $(window).height()) + 250) >= $(document).height()) {
                    if (loading == false) {
                        loading = true;
                        $.get("/wechat/GetCheapData?datetime=" + bttime, function (loaded) {
                            $('#content').append(loaded);
                            loading = false;
                            $(".datarow").unbind("click")
                .click(function () {
                    var shop = $(this).data("shop");
                    var id = $(this).data("id");
                    window.location.href = "/WeChat/ProductDetail?shop=" + shop + "&id=" + id;
                });
                        }
                        );
                    }
                }
            }
            );
        });




    </script>
}
